package com.wy.business.market.apps.actions;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.wy.business.market.apps.services.NewAuditService;
import com.wy.business.market.message.services.ContactsService;
import com.wy.framework.actions.AbstractBaseAction;
import com.wy.framework.dao.ErrorSqlException;
import com.wy.framework.exceptions.ServiceException;
import com.wy.framework.services.permission.RoleManageService;
import com.wy.component.dataConvert.JsonUtil;
import com.wy.component.dataConvert.StringUtil;

/**
 * 项目名称：openportal
 * 类名称：NewAuditAction
 * 类描述：我的APP仓库_新应用审核
 * 创建人：张旭星
 * 创建时间：2016-3-21 上午11:45:33
 * 修改人：张旭星
 * 修改时间：2016-3-21 上午11:45:33
 * 版本信息：@version 1.0
 * Copyright (c) 2016万雍科技（上海）有限公司-版权所有  
 * 修改备注：
 * @version 
 */
@ParentPackage("json")
@Namespace("/apps/newAudit")
@ExceptionMappings({ @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") })
public class NewAuditAction extends AbstractBaseAction {
	private static final long serialVersionUID = 1L;
	private static Log logger = LogFactory.getLog(NewAuditAction.class);

	@Autowired
	private NewAuditService newAuditService;
	
	@Autowired
	private ContactsService contactsService;
	
	@Autowired RoleManageService roleManageService;
	
	private List<Map> rows;
	private List<Map> orgInfo;
	private String id;
	private String jsonRes;
	private String orgCode;
	/**
	 * Function Name               list                                   
	 * @return
	 * @throws ServiceException          		             
	 * @description APP管理
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-1-4 下午1:46:43           张旭星                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Action(value = "list", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String list() throws ServiceException {
		String tab = ServletActionContext.getRequest().getParameter("tab");
		try {
			rows = newAuditService.list(tab);
		} catch (ErrorSqlException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryAppInfoByFunctionId                                   
	 * @return
	 * @throws Exception 
	 * @description 根据functionId查询一个app对象
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-23 上午11:50:06           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Action(value = "queryAppInfoByFunctionId", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryAppInfoByFunctionId() throws Exception {
		String functionId = ServletActionContext.getRequest().getParameter("params");
		String pageSize = ServletActionContext.getRequest().getParameter("pageSize");
		String pageNum = ServletActionContext.getRequest().getParameter("pageNum");
		try {
			
			List<Object> paramList = new ArrayList();
			paramList.add(functionId);
			rows = newAuditService.queryAppInfoByFunctionId(paramList);
			Map map=new HashMap<Object,List>();
			List list=newAuditService.queryPicUrl(paramList);
			map.put("picUrl", list);
			List list1=newAuditService.querylocalNetwork(paramList);
			map.put("netWork", list1);
			
			List list2=newAuditService.queryAllClassify();
			map.put("classify", list2);
			
			//第二页初始化第一个类别的接口信息
			map.put("secondInit", queryInterfaceByFirstClassifyIdMethod());
			
			//第三页初始化第一个机构下的人员数据
//			map.put("thirdInitUserInfo",thirdInitUserInfo());
			
			int size = StringUtils.isEmpty(pageSize) ? 10 : Integer.parseInt(pageSize);
			int num = StringUtils.isEmpty(pageSize) ? 1 : Integer.parseInt(pageNum);
			map.put("thirdInitUserInfoPage",thirdInitUserInfoPage(size, num));
			//第三页初始化第一个机构下的角色数据
//			map.put("thirdInitRoleInfo",queryInitRoleByFirstOrgInfo());
			map.put("queryInitRoleByFirstOrgInfoPage",queryInitRoleByFirstOrgInfoPage(size, num));
			map.put("orgCode",orgCode);
			//第四页推荐分类数据
			map.put("fourCategroyInfo", newAuditService.queryCategoryInfoAttrIsZero());
			
			//第二页已选接口数据
			map.put("hasSelectedIntegerface", newAuditService.queryHasSelectedIntegerface(paramList));
			
			//第三页已选应用授权用户的数据
			map.put("queryHasSelectedAppUser", newAuditService.queryHasSelectedAppUser(paramList));
			
			//第三页已选应用授权角色的数据
			map.put("queryHasSelectedAppRole", newAuditService.queryHasSelectedAppRole(paramList));
			
			//第四页 分类信息
			map.put("queryOldCategroyData", newAuditService.queryOldCategroyData(paramList));			
			
			rows.add(map);
		} catch (ErrorSqlException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryAppInfoByFunctionId                                   
	 * @return
	 * @throws Exception 
	 * @description 根据functionId查询一个app对象,升级待审查询
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-23 上午11:50:06          朱仕稳                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Action(value = "queryAppInfoByFunctionIdForUpGuade", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryAppInfoByFunctionIdForUpGuade() throws Exception {
		String functionId = ServletActionContext.getRequest().getParameter("params");
		String pageSize = ServletActionContext.getRequest().getParameter("pageSize");
		String pageNum = ServletActionContext.getRequest().getParameter("pageNum");
		try {
			
			List<Object> paramList = new ArrayList();
			paramList.add(functionId);
			rows = newAuditService.queryAppInfoByFunctionIdForUpGuade(paramList);
			Map map=new HashMap<Object,List>();
			List list=newAuditService.queryPicUrl(paramList);
			map.put("picUrl", list);
			List list1=newAuditService.querylocalNetwork(paramList);
			map.put("netWork", list1);
			
			List list2=newAuditService.queryAllClassify();
			map.put("classify", list2);
			
			//第二页初始化第一个类别的接口信息
			map.put("secondInit", queryInterfaceByFirstClassifyIdMethod());
			
//			//第三页初始化第一个机构下的人员数据
//			map.put("thirdInitUserInfo",thirdInitUserInfo());
//			
//			//第三页初始化第一个机构下的角色数据
//			map.put("thirdInitRoleInfo",queryInitRoleByFirstOrgInfo());
			int size = StringUtils.isEmpty(pageSize) ? 10 : Integer.parseInt(pageSize);
			int num = StringUtils.isEmpty(pageSize) ? 1 : Integer.parseInt(pageNum);
			map.put("thirdInitUserInfoPage",thirdInitUserInfoPage(size, num));
			//第三页初始化第一个机构下的角色数据
//			map.put("thirdInitRoleInfo",queryInitRoleByFirstOrgInfo());
			map.put("queryInitRoleByFirstOrgInfoPage",queryInitRoleByFirstOrgInfoPage(size, num));
			map.put("orgCode",orgCode);
			//第四页推荐分类数据
			map.put("fourCategroyInfo", newAuditService.queryCategoryInfoAttrIsZero());
			
			//第二页已选接口数据
			map.put("hasSelectedIntegerface", newAuditService.queryHasSelectedIntegerface(paramList));
			
			//第三页已选应用授权用户的数据
			map.put("queryHasSelectedAppUser", newAuditService.queryHasSelectedAppUser(paramList));
			
			//第三页已选应用授权角色的数据
			map.put("queryHasSelectedAppRole", newAuditService.queryHasSelectedAppRole(paramList));
			
			//第四页 分类信息
			map.put("queryOldCategroyData", newAuditService.queryOldCategroyData(paramList));			
			
			rows.add(map);
		} catch (ErrorSqlException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryAllClassify                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 查询所有的分类信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午1:47:45           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Action(value = "queryAllClassify", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false","root","rows"}) })
	public String queryAllClassify() throws Exception{
		rows=newAuditService.queryAllClassify();
		return SUCCESS;
	}
	
	
	/**
	 * 
	 * Function Name               queryInterfaceByFirstClassifyId                                   
	 * @return
	 * @throws Exception          		             
	 * @description 取得第一个分类下的接口信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-25 上午11:05:37           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "queryInterfaceByFirstClassifyId", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryInterfaceByFirstClassifyId() throws Exception{
		
		List list=newAuditService.queryAllClassify();
		String firstId="";
		if(list!=null && list.size() >0){
			Map<String,Object> map=(Map<String, Object>) list.get(0);
			List childList=(List) map.get("children");
			map=(Map<String, Object>) childList.get(0);
			firstId=(String) map.get("id");
		}
		
		List<Object> paramList = new ArrayList();
		paramList.add(firstId);
		rows=newAuditService.queryInterfaceByClassifyId(paramList);
		return SUCCESS;
	}
	
	
	/**
	 * 
	 * Function Name               queryInterfaceByFirstClassifyIdMethod                                   
	 * @return
	 * @throws Exception          		             
	 * @description 第二页初始化第一个类别的接口信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-26 上午11:44:49           黄忠                     Initial
	 **********************************************************************
	 */
	public List<Map> queryInterfaceByFirstClassifyIdMethod() throws Exception{
		List list=newAuditService.queryAllClassify();
		String firstId="";
		if(list!=null && list.size() >0){
			Map<String,Object> map=(Map<String, Object>) list.get(0);
			List childList=(List) map.get("children");
			map=(Map<String, Object>) childList.get(0);
			firstId=(String) map.get("id");
		}
		
		List<Object> paramList = new ArrayList();
		paramList.add(firstId);
		return newAuditService.queryInterfaceByClassifyId(paramList);
	}
	
	
	/**
	 * 
	 * Function Name               queryInterfaceByClassifyId                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 查询某个分类下的接口
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午2:58:31           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Action(value = "queryInterfaceByClassifyId", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryInterfaceByClassifyId() throws Exception{
		
		String id = ServletActionContext.getRequest().getParameter("id");
		List<Object> paramList = new ArrayList();
		paramList.add(id);
		rows=newAuditService.queryInterfaceByClassifyId(paramList);
		
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryOrginfo                                   
	 * @return
	 * @throws ErrorSqlException
	 * @throws FileNotFoundException
	 * @throws IOException          		             
	 * @description 查询所有部门信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午4:46:47           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "queryOrginfo", 
	interceptorRefs = { @InterceptorRef("sessionStack") }, 
	results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
	"false","root","rows"}) })
	public String queryOrginfo() throws ErrorSqlException, FileNotFoundException, IOException{
		rows=contactsService.queryOrgTree();
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryUserByOrgInfo                                   
	 * @return
	 * @throws Exception          		             
	 * @description 查询第一个机构下的人员信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午5:11:42           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Action(value = "queryUserByFirstOrgInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryUserByFirstOrgInfo() throws Exception{
		
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		paramList.add(firstOrgId);
		rows=newAuditService.queryUserByOrgInfo(paramList);
		return SUCCESS;
	}
	
	
	
	public List<Map> thirdInitUserInfo() throws Exception, ErrorSqlException, IOException{
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		paramList.add(firstOrgId);
		return newAuditService.queryUserByOrgInfo(paramList);
	}
	
	public List thirdInitUserInfoPage(Integer pageSize, Integer pageNum) throws Exception, ErrorSqlException, IOException{
		
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		orgCode= firstOrgId;
		paramList.add(firstOrgId);
		return newAuditService.queryUserByOrgInfoPage(paramList, pageSize, pageNum);
	}
	
	/**
	 * 
	 * Function Name               queryUserByOrgInfo                                   
	 * @return
	 * @throws Exception          		             
	 * @description 查询某个机构下的人员信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午5:11:42           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Action(value = "queryUserByOrgInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryUserByOrgInfo() throws Exception{
		String orgId = ServletActionContext.getRequest().getParameter("orgId");
		String pageSize = ServletActionContext.getRequest().getParameter("pageSize");
		String pageNum = ServletActionContext.getRequest().getParameter("pageNum");
		int size = StringUtils.isEmpty(pageSize) ? 10 : Integer.parseInt(pageSize);
		int num = StringUtils.isEmpty(pageSize) ? 1 : Integer.parseInt(pageNum);
		List<Object> paramList = new ArrayList();
		paramList.add(orgId);
		rows = newAuditService.queryUserByOrgInfoPage(paramList, size, num);
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryRoleByOrgInfo                                   
	 * @return
	 * @throws Exception          		             
	 * @description 查询第一个机构下的角色信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午5:53:24           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Action(value = "queryRoleByFirstOrgInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryRoleByFirstOrgInfo() throws Exception{
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		paramList.add(firstOrgId);
		rows=newAuditService.queryRoleByOrgInfo(paramList);
		return SUCCESS;
	}
	
	public List<Map> queryInitRoleByFirstOrgInfo() throws Exception{
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		paramList.add(firstOrgId);
		return newAuditService.queryRoleByOrgInfo(paramList);
	}
	
	public List queryInitRoleByFirstOrgInfoPage(Integer pageSize, Integer pageNum) throws Exception{
		List allOrgList=contactsService.queryOrgTree();
		String firstOrgId="";
		if(allOrgList !=null && allOrgList.size()>0) {
			Map map=(Map) allOrgList.get(0);
			firstOrgId=(String) map.get("id");
		}
		List<Object> paramList = new ArrayList();
		orgCode= firstOrgId;
		paramList.add(firstOrgId);
		return newAuditService.queryRoleByOrgInfoPage(paramList,pageSize,pageNum);
	}
	
	/**
	 * 
	 * Function Name               queryRoleByOrgInfo                                   
	 * @return
	 * @throws Exception          		             
	 * @description 查询某个机构下的角色信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-24 下午5:53:24           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "queryRoleByOrgInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String queryRoleByOrgInfo() throws Exception{
		String orgId = ServletActionContext.getRequest().getParameter("orgId");
		String pageSize = ServletActionContext.getRequest().getParameter("pageSize");
		String pageNum = ServletActionContext.getRequest().getParameter("pageNum");
		
		int size = StringUtils.isEmpty(pageSize) ? 10 : Integer.parseInt(pageSize);
		int num = StringUtils.isEmpty(pageSize) ? 1 : Integer.parseInt(pageNum);
		List<Object> paramList = new ArrayList();
		paramList.add(orgId);
		rows=newAuditService.queryRoleByOrgInfoPage(paramList, size, num);
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryCategoryInfoAttrIsZero                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 查询推荐分类信息
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-25 下午3:10:35           黄忠                     Initial
	 **********************************************************************
	 */
	@SuppressWarnings("unchecked")
	@Action(value = "queryCategoryInfoAttrIsZero", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false","root","rows"}) })
	public String queryCategoryInfoAttrIsZero() throws Exception{
		
		rows=newAuditService.queryCategoryInfoAttrIsZero();
		return SUCCESS;
	}
	
	
	/**
	 * 
	 * Function Name               addAppAuditInfo                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 保存新应用审核数据
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-26 下午4:33:35           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "addAppAuditInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String addAppAuditInfo() throws Exception{
		
		String appId = ServletActionContext.getRequest().getParameter("appId");
		String addNodesOrg = ServletActionContext.getRequest().getParameter("addNodesOrg");
		String addUserData = ServletActionContext.getRequest().getParameter("addUserData");
		String addRoleData = ServletActionContext.getRequest().getParameter("addRoleData");
		String fenlei = ServletActionContext.getRequest().getParameter("fenlei");
		String radioVal = ServletActionContext.getRequest().getParameter("radioVal");
		String descriptionFour = ServletActionContext.getRequest().getParameter("descriptionFour");
		String net_setting = ServletActionContext.getRequest().getParameter("net_setting");
		String ipStr = ServletActionContext.getRequest().getParameter("ipAddress");
		String ipDescStr = ServletActionContext.getRequest().getParameter("ipAddressDesc");
		String[] ipAddress=null,ipAddressDesc=null;
		if(StringUtils.isNotEmpty(ipStr)){
			ipAddress=ipStr.split(",");
			ipAddressDesc=ipDescStr.split(",");
		}
		
		try {
			boolean result=newAuditService.addAppAuditInfo(appId, addNodesOrg, addUserData, 
					addRoleData, fenlei, radioVal, descriptionFour,net_setting,ipAddress,ipAddressDesc);
			if(!result){
				return ERROR;
			}
		} catch (Exception e) {
			rspCode="999999";
			rspMsg = e.getMessage();
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	
	/**
	 * 
	 * Function Name               addAppAuditInfo                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 安全设置
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-26 下午4:33:35           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "updateAppInfo", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String updateAppInfo() throws Exception{
		
		String appId = ServletActionContext.getRequest().getParameter("appId");
		String addNodesOrg = ServletActionContext.getRequest().getParameter("addNodesOrg");
		String addUserData = ServletActionContext.getRequest().getParameter("addUserData");
		String addRoleData = ServletActionContext.getRequest().getParameter("addRoleData");
		String fenlei = ServletActionContext.getRequest().getParameter("fenlei");
		String radioVal = ServletActionContext.getRequest().getParameter("radioVal");
		String ipInfo = ServletActionContext.getRequest().getParameter("ipInfo");
		String disabledFlg = ServletActionContext.getRequest().getParameter("disabledFlg");
		try {
			boolean result=newAuditService.updateAppInfo(appId, addNodesOrg, addUserData, addRoleData, fenlei, radioVal, ipInfo,disabledFlg);
			if(!result){
				rspCode="999999";
				return ERROR;
			}
		} catch (Exception e) {
			rspCode="999999";
			rspMsg = e.getMessage();
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	/**
	 * 
	 * Function Name               queryHasSelectedOrg                                   
	 * @return          		             
	 * @throws Exception 
	 * @description 查询所有部门数据包含已勾选的
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-28 下午1:44:57           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "queryAllOrgToChecked", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false","root","rows"}) })
	public String queryAllOrgToChecked() throws Exception{
		
		String functionId = ServletActionContext.getRequest().getParameter("params");
		
		List<Object> paramList = new ArrayList();
		paramList.add(functionId);
		rows = newAuditService.queryAllOrgToChecked(paramList);
		jsonRes = JsonUtil.list2json(rows);
		return SUCCESS;
	}
	
	
	/**
	 * 
	 * Function Name               modifyAppUpDownState                                   
	 * @return
	 * @throws Exception          		             
	 * @description 修改上下架状态
	 * Modify History:              Date             Programmer       Notes
	 *                            ---------        ---------------  ---------
	 *                      2016-3-30 下午3:15:37           黄忠                     Initial
	 **********************************************************************
	 */
	@Action(value = "modifyAppUpDownState", 
			interceptorRefs = { @InterceptorRef("sessionStack") }, 
			results = { @Result(name = "success", type = "json", params = {
			"noCache", "true", "contentType", "text/html", "ignoreHierarchy",
			"false"}) })
	public String modifyAppUpDownState() throws Exception{
		
		String upDownState = ServletActionContext.getRequest().getParameter("upDownState");
		String functionId = ServletActionContext.getRequest().getParameter("params");
		
		List<Object> paramList = new ArrayList();
		paramList.add(upDownState);
		paramList.add(functionId);
		try {
			rows = newAuditService.modifyAppUpDownState(paramList);
		} catch (Exception e) {
			rspCode="999999";
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	
	
	
	
	
	
	public String getJsonRes() {
		return jsonRes;
	}

	public List<Map> getRows() {
		return rows;
	}

	public List<Map> getOrgInfo() {
		return orgInfo;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getTotal() {
		if (rows == null) {
			return 0;
		} else {
			return rows.size();
		}
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	
	

}
